package com.ywy.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import com.ywy.dao.ColorAndSizeMapper;
import com.ywy.entity.ColorAndSize;
import com.ywy.service.ColorAndSizeService;
import com.ywy.util.PageData;


@Service
public class ColorAndSizeServiceImpl implements ColorAndSizeService {
	@Autowired
	private ColorAndSizeMapper casm;
	@Override
	public PageData<ColorAndSize> getClothInfoBykey(int page, int pageSize, String key) {
		// TODO Auto-generated method stub
		int start = 0;
		if (page > 1) {
			start = (page - 1) * pageSize;
		}
		List<ColorAndSize> data = casm.getClothInfoBykey(start, pageSize, key);
		int totalCount = casm.getcountBykey(key);
		PageData<ColorAndSize> pageData = new PageData<>(data, totalCount, pageSize, page);
		//与layui的返回值要一致
		pageData.setCode(0);
		pageData.setMsg("");
		return pageData;
	}
	@Override
	public int getcountBykey(String key) {
		// TODO Auto-generated method stub
		return casm.getcountBykey(key);
	}

}
